<template>
  <div>
    <el-dialog
      :title="'客户名称'"
      :visible.sync="customerOpen"
      :width="'900px'"
      :height="'650px'"
      :before-close="handleClose"
    >
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" style="margin-top: -20px;">
        <el-form-item label="公司名称" prop="companyName" style="width: 33%">
          <el-input
            v-model="queryParams.companyName"
            placeholder="请输入项目名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="客户代码" prop="clientCode" style="width: 33%">
          <el-input
            v-model="queryParams.clientCode"
            placeholder="请输入客户代码"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="customerData" @selection-change="clientHandleChange" @row-dblclick="clientRowClick">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column property="clientCode" label="客户代码" width="100">
          <template slot-scope="scope">
            <div class="ellipsis">{{ scope.row.clientCode }}</div>
          </template>
        </el-table-column>
        <el-table-column property="companyName" label="公司名称" width="250">
          <template slot-scope="scope">
            <div class="ellipsis">{{ scope.row.companyName }}</div>
          </template>
        </el-table-column>
        <el-table-column property="heat" label="热度" width="80">
          <template slot-scope="scope">
            <div class="ellipsis">{{ scope.row.heat }}</div>
          </template>
        </el-table-column>
        <el-table-column property="valueEvaluate" label="价值评估">
          <template slot-scope="scope">
            <div class="ellipsis">{{ scope.row.valueEvaluate }}</div>
          </template>
        </el-table-column>
        <el-table-column property="creditRating" label="信用等级" width="150">
          <template slot-scope="scope">
            <div class="ellipsis">{{ scope.row.creditRating }}</div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          style=" margin-top: -5px;"
          class="dialog-paging"
          @pagination="getList"
      />
      <div slot="footer" class="dialog-footer" style=" margin-top: -30px;">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {listCustomerManagement} from "@/api/system/mis/customerManagement";

export default {
  name: "ProSelect",
  components: {  },
  dicts: ["sys_normal_disable", "sys_user_sex"],
  props: {
    width: {
      type: String,
      default: "900px",
    },
    height: {
      type: String,
      default: "650px",
    },
    customerOpen: {
      type: Boolean,
      default: false,
    },
  },
  computed: {},
  data() {
    return {
      loading: false,
      buttonLoading: false,
      customerData: [],
      customerList: [],
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        clientCode: undefined,
        companyName: undefined,
      },
    };
  },
  created() {
    this.getList();
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    },
  },
  methods: {
    handleClose(done) {
      this.cancel();
    },
    /** 查询客户列表 */
    getList() {
      this.loading = true;
      listCustomerManagement(this.queryParams).then(response => {
        this.total =response.total;
        this.customerData = response.rows;
        this.loading = false;
      });
    },
    // 客户列表点击数据
    clientHandleChange(row){
      this.customerList = row;
    },
    clientRowClick(row){
      this.customerList[0] = row;
      this.submitForm()
    },
    // 确认返回值
    submitForm() {
      this.$emit(
        "submit",
        this.customerList
      ); //返回username和nickname
    },
    cancel() {
      this.$emit("cancel");
    },
    // 搜索
    handleQuery() {
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        clientCode: undefined,
        projectManagerName: undefined,
      }
      this.getList()
    },
  },
};
</script>
<style>
.el-dialog__wrapper > .el-dialog {
  border-radius: 26px;
  height: 650px;
}
</style>
<style lang="scss" scoped>
.selectBox {
  width: 100%;
  min-width: 900px;
  display: flex;
  flex-direction: column;

  .topBox {
    width: 100%;
    display: flex;
    margin-top: 10px;
    .leftBox {
      width: 280px;
      height: 400px;
      margin-right: 10px;

      -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
        0 0 6px 0 rgba(0, 0, 0, 0.04);
      box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
      display: flex;
      flex-direction: column;

      .leftBox_title {
        width: 100%;
        height: 40px;
        font-size: 16px;
        line-height: 40px;
        padding-left: 10px;
        background-color: #f5f5f5;
        position: relative;
        .leftBox_title_do {
          position: absolute;
          right: 16px;
          top: 8px;
        }
      }

      .contentBox {
        width: 100%;
      }
    }
  }

  .bottomBox {
    margin-top: 15px;
    width: 100%;
    height: 75px;
    // border: 1px solid #DCDFE6;
    // -webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
    // box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12), 0 0 6px 0 rgba(0, 0, 0, 0.04);
    // overflow-y: auto;

    .selectPeopleList {
      width: 100%;
      display: flex;
      flex-wrap: wrap;

      .selectPeopleCard {
        width: 50px;
        height: 56px;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin: 5px 10px;
        .user-avatar {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          color: #fff;
          background: #ffa502;
          font-size: 14px;
          text-align: center;
          line-height: 40px;
        }

        .userInfo {
          width: 100%;
          display: flex;
          flex-direction: column;
          margin-left: 5px;
          margin-right: 5px;

          div:nth-child(1) {
            font-size: 14px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            width: 100%;
            text-align: center;
          }
        }
      }
    }
  }
}

.treeBox {
  width: 100%;
  height: 320px;
  overflow-x: hidden;
  overflow-y: auto;
}
.el-dialog{
  width: 900px;
  height: 650px;
}
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
//.el-dialog .dialog-paging {
//  position: absolute;
//  bottom: 40px;
//  width: 96%;
//  padding: 10px 20px; /* 根据需要调整内边距 */
//  text-align: right;
//  border-top: 0px solid #ebeef5;
//}
.peopleBox {
  width: 100%;
  height: 360px;
  overflow-x: hidden;
  overflow-y: auto;

  .peopleList {
    width: 100%;
    height: auto;

    .peopleCard:hover {
      background-color: #fafafa;
      transition: 0.2s;

      .peopleName {
        color: #eb6100;
      }
    }
    .peopleCard {
      width: 100%;
      height: 48px;
      border-top: solid #f5f5f5 1px;
      border-bottom: solid #f5f5f5 1px;
      padding-left: 8px;
      display: flex;
      align-items: center;
      cursor: pointer;
      transition: 0.2s;
      ::v-deep .el-checkbox__label {
        display: flex;
        align-items: center;
      }

      .avatarBox {
        width: 40px;
        height: 40px;

        .user-avatar {
          width: 40px;
          height: 40px;
          border-radius: 50%;
          color: #fff;
          font-size: 16px;
          text-align: center;
          line-height: 40px;
          user-select: none;
        }
      }

      .peopleInfoBox {
        width: 190px;
        height: 100%;
        display: flex;
        flex-direction: column;
        padding-left: 8px;

        .peopleName {
          width: 100%;
          height: 20px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 16px;
          line-height: 20px;
        }

        .peopleDept {
          width: 100%;
          height: 20px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          font-size: 14px;
          line-height: 20px;
          color: #999;
        }
      }

      .peopleDeleteBtn {
        width: 20px;
        height: 20px;
        // border-radius: 50%;
        // background: url(./delete2.png) no-repeat;
        background-size: 100% 100%;
        transition: 0.2s;
      }

      .peopleDeleteBtn:hover {
        width: 20px;
        height: 20px;
        // border-radius: 50%;
        // background: url(./delete1.png) no-repeat;
        background-size: 100% 100%;
        transition: 0.2s;
      }
    }
  }
}
</style>
